home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 July / EnigmA AMIGA RUN 20 (1997)(G.R. Edizioni)(IT)[!][issue 1997-07 & 08][EAR-CD IV].iso / earcd / mus / play / splibdev.lha / superplay-lib_DEV / Programmers / Example_SPObjects / ST / SP_RecogSubs.c < prev    next >
C/C++ Source or Header  |  1997-04-03  |  4KB  |  152 lines

  1. /*
  2. **      $VER: SP_RecogSubs.c 3.5 (26.1.97)
  3. **
  4. **      SPObject module binding and library initialization
  5. **
  6. **      (C) Copyright 1994-97 Andreas R. Kleinert
  7. **      All Rights Reserved.
  8. */
  9.  
  10. #include "spobject.h"
  11.  
  12. #include <exec/execbase.h>
  13. #include <exec/resident.h>
  14. #include <exec/initializers.h>
  15.  
  16. ULONG __saveds __stdargs SPLI_OpenLibs(void);
  17. void  __saveds __stdargs SPLI_CloseLibs(void);
  18. void  __saveds __stdargs SPLI_InitSPOList(void);
  19.  
  20. struct ExecBase      *SysBase               = N;
  21. struct DosLibrary    *DOSBase               = N;
  22. struct IntuitionBase *IntuitionBase         = N;
  23. struct GfxBase       *GfxBase               = N;
  24. struct Library       *UtilityBase           = N;
  25. struct XpkBase       *XpkBase               = N;
  26.  
  27. #define VERSION  3
  28. #define REVISION 5
  29.  
  30. char __aligned SVLibName [] = "ST.spobject";
  31. char __aligned SVLibID   [] = "ST 3.5 (26.1.97)";
  32. char __aligned Copyright [] = "(c) 1994-97 by Andreas R. Kleinert";
  33.  
  34. extern ULONG InitTab[];
  35.  
  36. extern APTR EndResident; /* below */
  37.  
  38. struct Resident ROMTag =
  39. {
  40.  RTC_MATCHWORD,
  41.  &ROMTag,
  42.  &EndResident,
  43.  RTF_AUTOINIT,
  44.  VERSION,
  45.  NT_LIBRARY,
  46.  0,
  47.  &SVLibName[0],
  48.  &SVLibID[0],
  49.  &InitTab[0]
  50. };
  51.  
  52. APTR EndResident;
  53.  
  54. struct MyDataInit
  55. {
  56.  UWORD ainit1; UWORD binit1; UWORD ln_type;
  57.  UBYTE ainit2; UBYTE binit2; ULONG ln_name2;
  58.  UWORD ainit3; UWORD binit3; UWORD lib_flags;
  59.  UWORD ainit4; UWORD binit4; UWORD lib_version;
  60.  UWORD ainit5; UWORD binit5; UWORD lib_revision;
  61.  UBYTE ainit6; UBYTE binit6; ULONG lib_idstring2;
  62.  ULONG end;
  63. } DataTab =
  64. {
  65.  INITBYTE(OFFSET(Node,         ln_Type),      NT_LIBRARY),
  66.  0x80, (UBYTE) OFFSET(Node,    ln_Name),      (ULONG) &SVLibName[0],
  67.  INITBYTE(OFFSET(Library,      lib_Flags),    LIBF_SUMUSED|LIBF_CHANGED),
  68.  INITWORD(OFFSET(Library,      lib_Version),  VERSION),
  69.  INITWORD(OFFSET(Library,      lib_Revision), REVISION),
  70.  0x80, (UBYTE) OFFSET(Library, lib_IdString), (ULONG) &SVLibID[0],
  71.  (ULONG) 0
  72. };
  73.  
  74. ULONG __saveds __stdargs SPLI_OpenLibs(void)
  75. {
  76.  SysBase = (*((struct ExecBase **) 4));
  77.  
  78.  
  79.  if(!FindSemaphore("splib_pre-init")) return(FALSE);
  80.  
  81.  DOSBase = (APTR) OpenLibrary("dos.library", 37);
  82.  if(!DOSBase) return(FALSE);
  83.  
  84.  IntuitionBase = (APTR) OpenLibrary("intuition.library", 37);
  85.  if(!IntuitionBase) return(FALSE);
  86.  
  87.  GfxBase = (APTR) OpenLibrary("graphics.library", 37);
  88.  if(!GfxBase) return(FALSE);
  89.  
  90.  UtilityBase = (APTR) OpenLibrary("utility.library", 37);
  91.  if(!UtilityBase) return(FALSE);
  92.  
  93.  return(TRUE);
  94. }
  95.  
  96. void __saveds __stdargs SPLI_CloseLibs(void)
  97. {
  98.  if(DOSBase)               CloseLibrary((APTR) DOSBase);
  99.  if(IntuitionBase)         CloseLibrary((APTR) IntuitionBase);
  100.  if(GfxBase)               CloseLibrary((APTR) GfxBase);
  101.  if(UtilityBase)           CloseLibrary((APTR) UtilityBase);
  102.  if(XpkBase)               CloseLibrary((APTR) XpkBase);
  103. }
  104.  
  105. void __saveds __stdargs SPLI_InitSPOList(void)
  106. {
  107.  struct SPO_ObjectNode *spo_node = N;
  108.  
  109.  SPObjectBase->spb_SPObject = N;
  110.  
  111.  if(FindSemaphore("splib_post-init"))
  112.   {
  113.    struct SuperPlayBase *SuperPlayBase = (APTR) OpenLibrary("superplay.library", 5);
  114.  
  115.    if(SuperPlayBase)
  116.     {
  117.      SPObjectBase->spb_SPObject = (APTR) FindName((APTR) &SuperPlayBase->spb_SPObjectList, "ST.spobject");
  118.  
  119.      CloseLibrary((APTR) SuperPlayBase);
  120.     }
  121.   }else
  122.   {
  123.    spo_node = AllocVec(sizeof(struct SPO_ObjectNode), (MEMF_CLEAR|MEMF_PUBLIC));
  124.  
  125.    if(!spo_node) return;
  126.  
  127.    SPObjectBase->spb_SPObject = spo_node;
  128.  
  129.    SPObjectBase->spb_SPObject = spo_node;
  130.  
  131.    ((struct Node *)spo_node)->ln_Type = NT_UNKNOWN;
  132.    ((struct Node *)spo_node)->ln_Pri  = -1;
  133.    ((struct Node *)spo_node)->ln_Name = N;
  134.  
  135.    spo_node->spo_Version = LibVer(SPObjectBase);
  136.    spo_node->spo_ObjectType = SPO_OBJECTTYPE_MODULE;
  137.  
  138.    strcpy(spo_node->spo_FileName, "ST.spobject");
  139.  
  140.    strcpy(spo_node->spo_TypeID, "SoundTracker");
  141.    spo_node->spo_TypeCode = N;                /* set by superplay.library */
  142.  
  143.    spo_node->spo_SubTypeNum = 1;
  144.  
  145.    strcpy(spo_node->spo_SubTypeID[0], "(ST)");
  146.  
  147.    spo_node->spo_SubTypeCode[0] = N;          /* set by superplay.library */
  148.  
  149.    spo_node->spo_BackgroundReplay = TRUE;
  150.   }
  151. }
  152.